<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2014/12/10
  Time: 16:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
          + request.getServerName() + ":" + request.getServerPort()
          + path + "/";
%>
<div class="row">
  <!-- NEW WIDGET START -->
  <article class="col-sm-12 col-md-12 col-lg-12">
    <div class="jarviswidget well" id="wid-id-3"
         data-widget-colorbutton="false"
         data-widget-editbutton="false"
         data-widget-togglebutton="false"
         data-widget-deletebutton="false"
         data-widget-fullscreenbutton="false"
         data-widget-custombutton="false"
         data-widget-sortable="false">
      <!-- widget div-->
      <div>
        <div class="widget-body">
          <a class="btn btn-default" id="btn-re-common" href="javascript:void(0);"><i class="fa fa-lg fa-mail-reply-all"></i>返回</a>
          <s:if test="design==null || isCreated(design.id)">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-confirm-common" href="javascript:void(0);"><i class="fa fa-rocket"></i> 提交</a>
          </s:if>
          <s:if test="isBacked(design.id)">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-recommit-common" href="javascript:void(0);"><i class="fa fa-rocket"></i> 再提交</a>
          </s:if>
          <s:if test="isApprove(1,design.id)">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-approve-common-1" href="javascript:void(0);"><i class="fa fa-fast-forward"></i> 审批通过</a>
          </s:if>
          <s:if test="isApprove(1,design.id)">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-reject-common-1" href="javascript:void(0);"><i class="fa fa-fast-backward"></i> 退回</a>
          </s:if>
          <s:if test="isApprove(2,design.id)">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-approve-common-2" href="javascript:void(0);"><i class="fa fa-fast-forward"></i> 审批通过</a>
          </s:if>
          <s:if test="isApprove(2,design.id)">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-reject-common-2" href="javascript:void(0);"><i class="fa fa-fast-backward"></i> 退回</a>
          </s:if>
          <s:if test="isApprove(3,design.id)">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-approve-common-3" href="javascript:void(0);"><i class="fa fa-fast-forward"></i> 审批通过</a>
          </s:if>
          <s:if test="isApprove(3,design.id)">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-reject-common-3" href="javascript:void(0);"><i class="fa fa-fast-backward"></i> 退回通过</a>
          </s:if>
          <a title="编辑" key="ajax_edit"  class="btn btn-default pull-right pull-right-fix <s:property value="isEdit(design.id)"/>" href="javascript:void(0);">
            <i class="fa fa-pencil-square-o"></i>编辑
          </a>
          <hr class="simple">
          <form id="design" class="smart-form" novalidate="novalidate" action="" method="post">
            <input type="hidden" name="keyId" id="keyId" value="<s:property value="design.id" />"/>
            <input type="hidden" name="curDutyId" id="curDutyId" value="<s:property value="curDutyId" />"/>
            <header id="title" style="display: block;">
              初步设计登记表
              <a href="javascript:void(0);" key="btn-comment">
                                    <span class="txt-color-blueDark pull-right">
                                        <i class="fa-fw fa fa-comment-o"></i> 审批意见<span></span>
                                    </span>
              </a>
            </header>
            <fieldset>
              <div class="row">
                <label class="label col col-2">
                  项目名称
                </label>
                <section class="col col-5">
                  <label class="input state-disabled" >
                    <input type="text" name="name" id="name" placeholder="请输入项目名称" disabled="disabled"value="<s:property value="design.project.name"/>">
                  </label>
                </section>
              </div>

              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  对应招标结果表
                </label>
                <section class="col col-5">
                  <label class="input state-disabled" >
                    <input type="text" name="bidresultname" id="bidresultname" placeholder="请输入招标结果表" disabled="disabled"value="<s:property value="design.bidResult.bidUnit"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">初步设计批复</label>
                <section class="col col-5">
                  <label class="input">
                      <input  name="uploadify" id="filename" placeholder="" style="display: none" value="<s:property value="design.fileId"/>" >
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">批复概算金额</label>
                <section class="col col-4">
                  <label class="input state-disabled">
                    <input name="replyMoney" id="replyMoney" placeholder="请输入批复概算金额"
                           value="<s:property value="formatMoney(design.replyMoney)"/>" disabled="disabled">
                  </label>
                </section>
                <label class="label col money-unit-form">万元</label>
              </div>
              <div class="row">
                <label class="label col col-2">批复日期</label>
                <section class="col col-2">
                  <label class="input state-disabled">
                    <input  class="hasDatepicker" name="replyDate" id="replyDate" placeholder="请选择批复日期"
                            type="text" value="<s:date name="design.replyDate" format="yyyy-MM-dd"/>" disabled="disabled">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">相关文号</label>
                <section class="col col-5">
                  <label class="input state-disabled">
                    <input name="relateNo" id="relateNo" placeholder="请输入备注"
                           type="text" value="<s:property value="design.relateNo"/>" disabled="disabled">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">其他专项审查上传</label>
                <section class="col col-5">
                  <label class="input">
                      <input  name="uploadify" id="filename1" placeholder="" style="display: none" value="<s:property value="design.othierFileId"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">备注</label>
                <section class="col col-5">
                  <label class="input state-disabled">
                    <input name="mark" id="mark" placeholder="请输入备注"
                           type="text" value="<s:property value="design.mark"/>" disabled="disabled">
                  </label>
                </section>
              </div>

              <div class="row">
                <label class="label col col-2">提交人</label>
                <section class="col col-2">
                  <label class="input state-disabled">
                    <input value="<s:property value="procreater.getName()"></s:property>" placeholder="" type="text" disabled="disabled">
                  </label>
                </section>
                <label class="label col col-1">提交日期</label>
                <section class="col col-2">
                  <label class="input state-disabled">
                    <input value="<s:date name="design.getCreateDate()" format="yyyy-MM-dd"></s:date>" placeholder="" type="text" disabled="disabled">
                  </label>
                </section>
              </div>
            </fieldset>
          </form>
        </div>
      </div>
    </div>
  </article>
</div>

<script>
  //上传文件
  readLoad({
    objId:"filename",
    entityName:"fileId",
    sourceId:"filename"
  });
  readLoad({
    objId:"filename1",
    entityName:"othierFileId",
    sourceId:"filename1"
  });

  //返回视图
  $("#btn-re-common").click(function(){
    loadURL("ajax!design.action",$('#content'));
  });
  $("a[key=ajax_edit]").click(function(){
    loadURL("ajax-design!input.action?keyId="+$("input#keyId").val(),$('#content'));
  });

</script>
<script type="text/javascript">
  $(function(){multiDuty()});
  //左侧意见栏
  $("a[key=btn-comment]").unbind("click").bind("click",function(){
    var keyId = $("input#keyId").val();
    var actionUrl = "ajax-running!comment.action?bussinessId="+keyId;
    var opt={title:"查看评论",type:"comment"};
    load_left_view($(this).attr("id"),actionUrl,opt);
    $("textarea[name='comment']").val("");
  })
  //第一步审批
  $("#btn-approve-common-1").click(
          function(e) {
            $.SmartMessageBox({
              title : "提示：",
              content : "确定提交申请吗？",
              buttons : '[取消][确认]'
            }, function(ButtonPressed) {
              if (ButtonPressed === "取消") {
                e.preventDefault();
                e.stopPropagation();
                return;
              }
              if (ButtonPressed === "确认") {
                $("#btn-approve-common-1").attr("disabled", "disabled");
                form_save("design","<%=path%>/com/ajax-design!approve1.action");
                loadURL("ajax!design.action",$('#content'));
              }
            });
          }
  );
  //第二步审批
  $("#btn-approve-common-2").click(
          function(e) {
            $.SmartMessageBox({
              title : "提示：",
              content : "确定提交申请吗？",
              buttons : '[取消][确认]'
            }, function(ButtonPressed) {
              if (ButtonPressed === "取消") {
                e.preventDefault();
                e.stopPropagation();
                return;
              }
              if (ButtonPressed === "确认") {
                $("#btn-approve-common-2").attr("disabled", "disabled");
                form_save("design","<%=path%>/com/ajax-design!approve2.action");
                loadURL("ajax!design.action",$('#content'));
              }
            });
          }
  );
  //第三步审批
  $("#btn-approve-common-3").click(
          function(e) {
            $.SmartMessageBox({
              title : "提示：",
              content : "确定提交申请吗？",
              buttons : '[取消][确认]'
            }, function(ButtonPressed) {
              if (ButtonPressed === "取消") {
                e.preventDefault();
                e.stopPropagation();
                return;
              }
              if (ButtonPressed === "确认") {
                $("#btn-approve-common-3").attr("disabled", "disabled");
                form_save("design","<%=path%>/com/ajax-design!approve3.action");
                loadURL("ajax!design.action",$('#content'));
              }
            });
          }
  );

  //提交
  $("#btn-confirm-common").click(
          function(e) {
            var $valid = $("#design").valid();
            if(!$valid){
              e.preventDefault();
              e.stopPropagation();
              return;
            }
            $.SmartMessageBox({
              title : "提示：",
              content : "确定提交申请吗？",
              buttons : '[取消][确认]'
            }, function(ButtonPressed) {
              if (ButtonPressed === "取消") {
                e.preventDefault();
                e.stopPropagation();
                return;
              }
              if (ButtonPressed === "确认") {
                var $validForm = $("#design").valid();
                if(!$validForm) return false;
                $("#btn-confirm-common").attr("disabled", "disabled");
                form_save("design","<%=path%>/com/ajax-design!commit.action");
                loadURL("ajax!design.action",$('#content'));
              }
            });
          }
  );


  $("#btn-reject-common-1").unbind().bind("click",function(e){
    $.SmartMessageBox({
      title : "提示：",
      content : "确定退回吗？",
      buttons : '[取消][确认]'
    }, function(ButtonPressed) {
      if (ButtonPressed === "取消") {
        e.preventDefault();
        e.stopPropagation();
        return;
      }
      if (ButtonPressed === "确认") {
        $("#btn-reject-common-1").attr("disabled", "disabled");
        var data={proDefKey:"usertask1",keyId:$("input#keyId").val(),numStatus:0}
        ajax_action("ajax-design!reject.action",data);
        loadURL("ajax!design.action",$('#content'));
      }
    });
  });

  $("#btn-reject-common-2").unbind().bind("click",function(e){
    $.SmartMessageBox({
      title : "提示：",
      content : "确定退回吗？",
      buttons : '[取消][确认]'
    }, function(ButtonPressed) {
      if (ButtonPressed === "取消") {
        e.preventDefault();
        e.stopPropagation();
        return;
      }
      if (ButtonPressed === "确认") {
        $("#btn-reject-common-2").attr("disabled", "disabled");
        var data={proDefKey:"usertask1",keyId:$("input#keyId").val(),numStatus:0}
        ajax_action("ajax-design!reject.action",data);
        loadURL("ajax!design.action",$('#content'));
      }
    });
  });
  $("#btn-reject-common-3").unbind().bind("click",function(e){
    $.SmartMessageBox({
      title : "提示：",
      content : "确定退回吗？",
      buttons : '[取消][确认]'
    }, function(ButtonPressed) {
      if (ButtonPressed === "取消") {
        e.preventDefault();
        e.stopPropagation();
        return;
      }
      if (ButtonPressed === "确认") {
        $("#btn-reject-common-3").attr("disabled", "disabled");
        var data={proDefKey:"usertask1",keyId:$("input#keyId").val(),numStatus:0}
        ajax_action("ajax-design!reject.action",data);
        loadURL("ajax!design.action",$('#content'));
      }
    });
  });


  //返回视图
  $("#btn-re-common").click(function(){
    loadURL("ajax!design.action",$('#content'));
  });
</script>

